package day13.KeJian;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

public class PropertiesDemo03 {
    public static void main(String[] args) throws IOException {
        myStore();
        //myLoad();
    }

    private static void myLoad() throws IOException {
        //把文件中的数据加载到集合
        Properties prop1 = new Properties();
        FileReader fr = new FileReader("D://itheima//nb.txt");
        prop1.load(fr);
        fr.close();

        System.out.println(prop1);
    }

    private static void myStore() throws IOException {
        //把集合中的数据保存到文件
        Properties prop = new Properties();
        prop.setProperty("heima001","张某某");
        prop.setProperty("heima001","王某某");
        prop.setProperty("heima001","李某某");
        FileWriter fw = new FileWriter("D://itheima//nb.txt");
        prop.store(fw,null);
        fw.close();
    }
}
